using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerController : MonoBehaviour
{
    // Start is called before the first frame update
    PuzzleBackend CachedBackend = null;
    void Start()
    {
        CachedBackend = GetComponentInParent<PuzzleBackend>();
    }

    // Update is called once per frame
    void Update()
    {
        var bPressedW = Input.GetKeyDown(KeyCode.W);
        var bPressedA = Input.GetKeyDown(KeyCode.A);
        var bPressedS = Input.GetKeyDown(KeyCode.S);
        var bPressedD = Input.GetKeyDown(KeyCode.D);
        var bPressedZ = Input.GetKeyDown(KeyCode.Z);
        var bPressedR = Input.GetKeyDown(KeyCode.R);

        if (CachedBackend != null)
        {
            if (bPressedW) CachedBackend.DealInput(InputType.Up);
            if (bPressedA) CachedBackend.DealInput(InputType.Left);
            if (bPressedS) CachedBackend.DealInput(InputType.Down);
            if (bPressedD) CachedBackend.DealInput(InputType.Right);


            if (bPressedZ) CachedBackend.DealInput(InputType.Back);
            if (bPressedR) CachedBackend.DealInput(InputType.Reset);
        }


    }
}
